﻿
using LxBasic;
using LxCore;

namespace LxCore.Samples
{
    public class AnistrophyHeatConduction : SampleVMBase
    {
        public AnistrophyHeatConduction() : base()
        {
            Name = "各向异性导热";
            FileName= "Case0-Chang.msh";
        }
        public override void RunCase()
        {
            //create physical model
            ReadFile();

            var physical = LxSim.Sim.Physics.CreatePhysicalModel();
            physical.PhysicalType = PhysicalTypes.固体;
            physical.IsEnergyEnabled = true;    
        
            var mat = physical.MaterialProperty;
            mat.ThermalAnisotropyType = AnisotropyTypes.各向异性;
            mat.k11 = new ConstField.Double(100);
            mat.k12 = ConstField.Double0;
            mat.k13 = ConstField.Double0;
            mat.k21 = ConstField.Double0;
            mat.k22 = new ConstField.Double(200);
            mat.k23 = ConstField.Double0;
            mat.k31 = ConstField.Double0;
            mat.k32 = ConstField.Double0;
            mat.k33 = new ConstField.Double(100);

            //set zone condition
            var z = FindZone("BODY");
            ResHelper.GetCond(z).PhysicalModel = physical;

            var t_IN = FindBound(z, "IN");
            ResHelper.GetCond(t_IN).WallThermalType = WallThermalTypes.定热流密度;
            ResHelper.GetCond(t_IN).HeatFlux_b = new ConstField.Double(300);

            var t_OUT = FindBound(z, "OUT");
            ResHelper.GetCond(t_OUT).WallThermalType = WallThermalTypes.定壁温;
            ResHelper.GetCond(t_OUT).Temperature = new ConstField.Double(300);

            //set monitor
            var monitor = LxSim.Sim.Monitors.CreateMonitor("IN面温度", StatisticTypes.AreaAverage);
            monitor.ScalarType = ScalarFieldTypes.Temperature;
            monitor.SetSelector(t_IN, true);


            //run computation
            LxSim.Sim.Steps.IterationStep.MaxStepRule.MaxStep = 300;
            MultiThreads.SetThreadsCount(1);

            RunSimulation();

        }
    }
}
